/**
 * 自定义toast
 */

function customToast(config) {
  if (!config) return
  let uniToastConfig = {}
  if (typeof config === 'string') {
    uniToastConfig.title = config
    uniToastConfig.icon = 'none'
  } else {
    uniToastConfig = config
  }
  console.log(uniToastConfig);
  uni.showToast(uniToastConfig)
}

function toast(config) {
  customToast(config)
}
toast.success = function(tilte, config = {}) {
  config.title = tilte
  config.icon = 'success'
  customToast(config)
}
toast.warning = function(tilte, config = {}) {
  config.title = tilte
  config.icon = 'none'
  customToast(config)
}
toast.error = function(tilte, config = {}) {
  config.title = tilte
  config.icon = 'none'
  customToast(config)
}
toast.loading = function(tilte, config = {}) {
  config.title = tilte
  config.icon = 'loading'
  customToast(config)
}
export {
  toast
}
